<template>
  
    <el-tree ref="tree" :data="data" :props="defaultProps"  node-key="catId" @node-click="nodeClick">
    </el-tree>



</template>

<script>



export default {
  data() {
    return {
      data: [],
      defaultProps: {
        children: 'children',
        label: 'name',
      }
    }
  },
  methods: {
    fetchTreeData() { //请求分类数据
      this.$http({
        url: this.$http.adornUrl('/product/category/list/tree'),
        method: 'get'
      }).then(({ data }) => {
        console.log(data)
        this.data = data.page
      })
    },
    nodeClick(data,node,tree){ 
        this.$emit("tree-node-click",data)
    }
  },
  created() {
    this.fetchTreeData()
  }
}

</script>

